package com.entity;

import com.util.GameUtil;
import com.view.GameFrame;

import java.awt.*;
import java.util.Random;

/**
 * @author: Combo
 * @time: 2021/1/4 15:46
 * @description: 障碍物 —— 鱼叉
 */
public class Harpoon {

    private Image image;
    private Image[] images;
    public static final int WIDTH = 150;
    public static final int HEIGHT = 350;
    private Integer x;
    private Integer y;

    public Harpoon() {
        Random random = new Random();
        init();
        image = images[random.nextInt(4)];
        x = GameFrame.WIDTH + 1500;
        y = 0;
    }

    public void step(){
        x -= 20;
    }

    public void paintHarpoon(Graphics g){
        g.drawImage(image, x, y, WIDTH, HEIGHT, null);
    }

    public boolean outOfBounds(){
        return this.x <= -WIDTH;
    }

    public void init(){
        images = new Image[4];
        for (int i = 0; i < images.length; i++){
            images[i] = GameUtil.getImage("images/harpoon/"+ (i+1) +".png");
        }
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public Image[] getImages() {
        return images;
    }

    public void setImages(Image[] images) {
        this.images = images;
    }

    public static int getWIDTH() {
        return WIDTH;
    }

    public static int getHEIGHT() {
        return HEIGHT;
    }

    public Integer getX() {
        return x;
    }

    public void setX(Integer x) {
        this.x = x;
    }

    public Integer getY() {
        return y;
    }

    public void setY(Integer y) {
        this.y = y;
    }
}
